package com.lgx.common.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.lgx.common.web.util.DateUtils;

import net.sf.json.JSONObject;

/**
 * IP对应地区
 * 
 * @author hz
 *
 */
@Entity
@Table(name = "TS_INTRA_CITY")
public class IntraCity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2972221525749990554L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TS_INTRA_CITY_ID)
	@TableGenerator(
			name = IdGenerator.TS_INTRA_CITY_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TS_INTRA_CITY_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private Long id;
	
	/**
	 * 开始IP
	 */
	private String beginIp;
	
	/**
	 * 结束IP
	 */
	private String endIp;
	
	/**
	 * 区号
	 */
	private String areaNode;
	
	/**
	 * 名称
	 */
	private String areaName;
	
	/**
	 * 城市
	 */
	private String areaId;
	
	private Date createDate;
	
	private String createName;

	public String getAreaId() {
		return areaId;
	}

	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getBeginIp() {
		return beginIp;
	}

	public void setBeginIp(String beginIp) {
		this.beginIp = beginIp;
	}

	public String getEndIp() {
		return endIp;
	}

	public void setEndIp(String endIp) {
		this.endIp = endIp;
	}

	public String getAreaNode() {
		return areaNode;
	}

	public void setAreaNode(String areaNode) {
		this.areaNode = areaNode;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getCreateName() {
		return createName;
	}

	public void setCreateName(String createName) {
		this.createName = createName;
	}

	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("createName", this.getCreateName());
		obj.put("createDate", DateUtils.dateToChar(getCreateDate(), DateUtils.DATE_FORMAT_ZH));
		obj.put("areaName", getAreaName());
		obj.put("areaNode", getAreaNode());
		obj.put("areaId", getAreaId());
		
		return obj.toString();
	}
}
